package guda.shop.cms.manager.impl;

import guda.shop.cms.dao.ProductTypePropertyDao;
import guda.shop.cms.entity.ProductTypeProperty;
import guda.shop.cms.manager.ProductTypePropertyMng;
import guda.shop.common.hibernate3.Updater;
import guda.shop.common.page.Pagination;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Iterator;
import java.util.List;

@Service
@Transactional
public class ProductTypePropertyMngImpl
        implements ProductTypePropertyMng {

    @Autowired
    private ProductTypePropertyDao productTypePropertyDao;

    public ProductTypeProperty deleteById(Long paramLong) {
        return this.productTypePropertyDao.deleteById(paramLong);
    }

    public ProductTypeProperty[] deleteByIds(Long[] paramArrayOfLong) {
        ProductTypeProperty[] arrayOfProductTypeProperty = new ProductTypeProperty[paramArrayOfLong.length];
        int i = 0;
        int j = paramArrayOfLong.length;
        while (i < j) {
            arrayOfProductTypeProperty[i] = deleteById(paramArrayOfLong[i]);
            i++;
        }
        return arrayOfProductTypeProperty;
    }

    public ProductTypeProperty findById(Long paramLong) {
        return this.productTypePropertyDao.findById(paramLong);
    }

    public Pagination getList(int paramInt1, int paramInt2, Long paramLong, Boolean paramBoolean, String paramString1, String paramString2) {
        return this.productTypePropertyDao.getList(paramInt1, paramInt2, paramLong, paramBoolean, paramString1, paramString2);
    }

    public List<ProductTypeProperty> getList(Long paramLong, Boolean paramBoolean) {
        return this.productTypePropertyDao.getList(paramLong, paramBoolean);
    }

    public void saveList(List<ProductTypeProperty> paramList) {
        Iterator localIterator = paramList.iterator();
        while (localIterator.hasNext()) {
            ProductTypeProperty localProductTypeProperty = (ProductTypeProperty) localIterator.next();
            save(localProductTypeProperty);
        }
    }

    public ProductTypeProperty save(ProductTypeProperty paramProductTypeProperty) {
        return this.productTypePropertyDao.save(paramProductTypeProperty);
    }

    public void updatePriority(Long[] paramArrayOfLong, Integer[] paramArrayOfInteger, String[] paramArrayOfString, Boolean[] paramArrayOfBoolean) {
        int i = 0;
        int j = paramArrayOfLong.length;
        while (i < j) {
            ProductTypeProperty localProductTypeProperty = findById(paramArrayOfLong[i]);
            localProductTypeProperty.setPropertyName(paramArrayOfString[i]);
            localProductTypeProperty.setSort(paramArrayOfInteger[i]);
            localProductTypeProperty.setSingle(paramArrayOfBoolean[i]);
            i++;
        }
    }

    public List<ProductTypeProperty> findBySearch(String paramString1, String paramString2) {
        return this.productTypePropertyDao.findBySearch(paramString1, paramString2);
    }

    public List<ProductTypeProperty> findListByTypeId(Long paramLong) {
        return this.productTypePropertyDao.findListByTypeId(paramLong);
    }

    public List<ProductTypeProperty> getList(Long paramLong, boolean paramBoolean) {
        return this.productTypePropertyDao.getList(paramLong, paramBoolean);
    }

    public ProductTypeProperty update(ProductTypeProperty paramProductTypeProperty) {
        Updater localUpdater = new Updater(paramProductTypeProperty);
        ProductTypeProperty localProductTypeProperty = this.productTypePropertyDao.updateByUpdater(localUpdater);
        return localProductTypeProperty;
    }
}

